<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>游戏解包与源码查看工具</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        .file-tree {
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid #dee2e6;
            border-radius: 0.375rem;
        }
        .file-item {
            cursor: pointer;
            padding: 0.25rem 0.5rem;
            border-bottom: 1px solid #f8f9fa;
        }
        .file-item:hover {
            background-color: #f8f9fa;
        }
        .file-item.active {
            background-color: #0d6efd;
            color: white;
        }
        .code-viewer {
            max-height: 500px;
            overflow-y: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 0.875rem;
            background-color: #f8f9fa;
            padding: 1rem;
            border-radius: 0.375rem;
        }
        .progress-custom {
            height: 2px;
            margin: 0.5rem 0;
        }
        .status-card {
            transition: all 0.3s ease;
        }
        .status-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-dark bg-primary">
        <div class="container-fluid">
            <span class="navbar-brand mb-0 h1">
                <i class="fas fa-gamepad"></i> 游戏解包与源码查看工具
            </span>
        </div>
    </nav>

    <div class="container-fluid mt-4">
        <div class="row">
            <!-- 上传区域 -->
            <div class="col-md-4">
                <div class="card">
                    <div class="card-header">
                        <h5><i class="fas fa-upload"></i> 上传游戏包</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">选择游戏文件</label>
                            <input type="file" class="form-control" id="gameFile" accept=".apk,.ipa,.zip,.exe">
                            <div class="form-text">支持 APK、IPA、Unity、Unreal、HTML5 格式</div>
                        </div>
                        <button class="btn btn-primary w-100" onclick="uploadFile()">
                            <i class="fas fa-cloud-upload-alt"></i> 上传并解包
                        </button>
                        <div class="progress mt-3" style="display: none;" id="uploadProgress">
                            <div class="progress-bar progress-bar-striped progress-bar-animated" 
                                 role="progressbar" style="width: 0%"></div>
                        </div>
                    </div>
                </div>

                <!-- 文件树 -->
                <div class="card mt-3">
                    <div class="card-header">
                        <h5><i class="fas fa-folder-tree"></i> 文件结构</h5>
                    </div>
                    <div class="card-body p-0">
                        <div class="file-tree" id="fileTree">
                            <div class="text-center text-muted p-3">
                                <i class="fas fa-info-circle"></i> 请先上传游戏包
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 内容查看区域 -->
            <div class="col-md-8">
                <!-- 搜索区域 -->
                <div class="card mb-3">
                    <div class="card-header">
                        <h5><i class="fas fa-search"></i> 源码搜索</h5>
                    </div>
                    <div class="card-body">
                        <div class="input-group">
                            <input type="text" class="form-control" id="searchInput" 
                                   placeholder="搜索源码内容..." disabled>
                            <button class="btn btn-outline-secondary" type="button" 
                                    onclick="searchFiles()" disabled id="searchBtn">
                                <i class="fas fa-search"></i> 搜索
                            </button>
                        </div>
                    </div>
                </div>

                <!-- 文件内容 -->
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h5><i class="fas fa-code"></i> 文件内容</h5>
                        <div>
                            <button class="btn btn-sm btn-success" onclick="runGame()" 
                                    disabled id="runBtn">
                                <i class="fas fa-play"></i> 运行游戏
                            </button>
                            <button class="btn btn-sm btn-info" onclick="generateReport()" 
                                    disabled id="reportBtn">
                                <i class="fas fa-file-alt"></i> 生成报告
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <div id="fileContent">
                            <div class="text-center text-muted p-5">
                                <i class="fas fa-file-code fa-3x mb-3"></i>
                                <h5>选择文件查看内容</h5>
                                <p>点击左侧文件树中的文件来查看源码</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 搜索结果 -->
                <div class="card mt-3" id="searchResults" style="display: none;">
                    <div class="card-header">
                        <h5><i class="fas fa-list"></i> 搜索结果</h5>
                    </div>
                    <div class="card-body">
                        <div id="searchResultsList"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 运行模态框 -->
    <div class="modal fade" id="runModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">游戏运行</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <iframe id="gameFrame" style="width: 100%; height: 500px; border: none;"></iframe>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
    <script src="static/js/app.js"></script>
</body>
</html>